package cn.crc.tcp;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.Socket;

public class DemoTcpClient {
    public static void main(String[] args) {
        DemoTcpClient.receiveMsg();
    }

    public static void receiveMsg(){
        Socket clientsocket = null;
        BufferedWriter writer = null;
        try {
            clientsocket = new Socket("localhost",8888);
            writer = new BufferedWriter(new OutputStreamWriter(clientsocket.getOutputStream()));
            writer.write("Hello, Tcp server!");
            writer.flush();
            clientsocket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
